package com.ruoyi.source.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.source.api.domain.SrcGoStore;
import com.ruoyi.source.domain.vo.SrcGoStoreVo;
import com.ruoyi.source.domain.vo.SrcInStoreVo;
import com.ruoyi.source.service.ISrcGoStoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 出口Controller
 * 
 * @author ruoyi
 * @date 2024-07-27
 */
@RestController
@RequestMapping("/go/store")
public class SrcGoStoreController extends BaseController {
    @Autowired
    private ISrcGoStoreService srcGoStoreService;

    /**
     * 查询出口列表
     */
    @RequiresPermissions("source:go:list")
    @GetMapping("/list")
    public TableDataInfo list(SrcGoStore srcGoStore) {
        startPage();
        List<SrcGoStoreVo> list = srcGoStoreService.selectSrcGoStoreList(srcGoStore);
        return getDataTable(list);
    }

    /**
     * 导出出口列表
     */
    /*@RequiresPermissions("source:go:export")
    @Log(title = "出口", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SrcGoStore srcGoStore)
    {
        List<SrcGoStore> list = srcGoStoreService.selectSrcGoStoreList(srcGoStore);
        ExcelUtil<SrcGoStore> util = new ExcelUtil<SrcGoStore>(SrcGoStore.class);
        util.exportExcel(response, list, "出口数据");
    }*/

    /**
     * 获取出口详细信息
     */
    @RequiresPermissions("source:go:query")
    @GetMapping(value = "/{goStoreId}")
    public AjaxResult getInfo(@PathVariable("goStoreId") Long goStoreId) {
        return success(srcGoStoreService.selectSrcGoStoreByGoStoreId(goStoreId));
    }

    /**
     * 新增出口
     */
    @RequiresPermissions("source:go:add")
    @Log(title = "出口", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SrcGoStore srcGoStore) {
        return toAjax(srcGoStoreService.insertSrcGoStore(srcGoStore));
    }

    /**
     * 修改出口
     */
    @RequiresPermissions("source:go:edit")
    @Log(title = "出口", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SrcGoStore srcGoStore) {
        return toAjax(srcGoStoreService.updateSrcGoStore(srcGoStore));
    }

    /**
     * 删除出口
     */
    @RequiresPermissions("source:go:remove")
    @Log(title = "出口", businessType = BusinessType.DELETE)
	@DeleteMapping("/{goStoreIds}")
    public AjaxResult remove(@PathVariable Long[] goStoreIds) {
        return toAjax(srcGoStoreService.deleteSrcGoStoreByGoStoreIds(goStoreIds));
    }
}
